using Game.Main.Model;
using UnityEngine;

namespace Game.Component
{
	public class EyeMachineBoxItem : BaseItem
	{
		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override bool AttachItem(BaseItem item, DepthType depthType, AttachType attachType, bool updatePosition)
		{
			bool result = base.AttachItem(item, depthType, attachType, updatePosition);
			if (parentItem != null && parentItem.itemData.scriptType == 109)
			{
				if (item.itemData.scriptType == 1)
				{
					((EyeMachineItem)parentItem).SetTargetCharacter(item);
				}
				else
				{
					((EyeMachineItem)parentItem).AddEyeTestTool(item);
				}
			}
			return result;
		}

		public override void ReleaseAttachItem(BaseItem item)
		{
			base.ReleaseAttachItem(item);
			if (parentItem != null && parentItem.itemData.scriptType == 109)
			{
				if (item.itemData.scriptType == 1)
				{
					((EyeMachineItem)parentItem).SetTargetCharacter(null);
				}
				else
				{
					((EyeMachineItem)parentItem).RemoveEyeTestTool(item);
				}
			}
		}

		public void ReleaseEyeTestTool()
		{
			for (int num = childItems.Count - 1; num >= 0; num--)
			{
				BaseItem baseItem = childItems[num];
				ReleaseAttachItem(baseItem);
				baseItem.DropDown(new Vector3(baseItem.transform.position.x, base.transform.position.y, baseItem.transform.position.z));
			}
		}
	}
}
